<template>
  <basic-container>
    <el-button @click="goback()" type="primary" style="position:absolute;left: 10px;top:10px">返回主菜单</el-button>
    <div class="form_border">
      <div class="icon_border">
        <div style="height: 100px">
          <img style="width: auto;height: auto;max-width: 100%;max-height: 100%" :src="appsflyerLogo" alt="">
        </div>
      </div>
      <div class="form_title">请输入APPsflyer的usertoken:</div>
      <div style="display: flex">
        <el-input show-password  auto-complete="new-password" style="width: 60%;margin-right: 5%" v-model="appsflyerToken"></el-input>
        <el-button type="primary" @click="saveAFToken">保 存</el-button>
      </div>
    </div>
    <div class="form_border" style="margin-top: 20px">
      <div class="icon_border">
        <div style="height: 52px;">
          <img style="width: auto;height: auto;max-width: 100%;max-height: 100%" :src="adjustLogo" alt="">
        </div>
      </div>
      <div class="form_title">请输入adjust的usertoken:</div>
      <div style="display: flex">
        <el-input show-password auto-complete="new-password" style="width: 60%;margin-right: 5%" v-model="adjustToken"></el-input>
        <el-button type="primary" @click="saveADToken">保 存</el-button>
      </div>

    </div>
  </basic-container>
</template>

<script>
import {backToken, submitToken} from "@/api/business/appManager";

export default {
  name: "thirdpartyConfig",
  data() {
    return {
      adjustToken: '',
      appsflyerToken: '',
      icon: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      adjustLogo: '/img/icon/adjust_logo.png',
      appsflyerLogo: '/img/icon/appsFlyer_logo.png',
    }
  },
  created() {
    //获取token  adjust
    backToken(0).then(res => {
      if (res.data.data !== '-1') {
        this.adjustToken = res.data.data
      }
    })
    //获取token appsflyer
    backToken(1).then(res => {
      if (res.data.data !== '-1') {
        this.appsflyerToken = res.data.data
      }
    })
  },
  methods: {
    goback(){
      this.$router.go("/system/Navigation");//返回上一层
    },
    /**
     * 保存 AF token
     */
    saveAFToken() {
      submitToken({platform: 1, userToken: this.appsflyerToken}).then(res => {
        if (res.data.data) {
          this.$message({
            type: 'success',
            message: '保存成功!'
          })
        }
      })
    },
    /**
     * 保存 AD token
     */
    saveADToken() {
      submitToken({platform: 0, userToken: this.adjustToken}).then(res => {
        if (res)
          this.$message({
            type: 'success',
            message: '保存成功!'
          })
      })
    }
  }
}
</script>

<style scoped lang="scss">
.icon_border {
  display: flex;
  margin-left: 40px;
  margin-bottom: 40px;

  :nth-child(1) {
    height: 80px;

    img {
      width: 100%;
      height: 100%;
    }
  }

  :nth-child(2) {
    line-height: 80px;
    margin-left: 10px;
    font-size: 18px;
    font-weight: 500;
  }
}

.form_title {
  color: #00a2ff;
  margin-bottom: 10px;
  font-size: 17px;
}

.form_border {
  width: 60%;
}
</style>
